<?php

namespace App\Jobs;

use App\Models\InvestmentMeeting;
use App\Models\Manufacturer;
use App\Services\ImageServices;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class buildCardJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(public Manufacturer $info, public InvestmentMeeting $meeting_info)
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        ImageServices::deleteFolder(storage_path('app/public/invite/' . $this->meeting_info->title . '_' . $this->meeting_info->id . '/' . $this->info->title . '_' . $this->info->id));
        $this->info->invitation_path = ImageServices::buildInvite($this->meeting_info, $this->info);
        $this->info->hand_card_path = ImageServices::buildCard($this->meeting_info, $this->info);
        $this->info->save();
    }
}
